﻿using System;
using System.Threading.Tasks;
using Devonline.Entity;

namespace Devonline.MessageClient
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("请输入发送者:");
            var sender = Console.ReadLine();

            Console.WriteLine("请输入接收者:");
            var receiver = Console.ReadLine();

            Console.WriteLine("请输入任意内容, 按回车发送消息!");

            var client = new Client("ws://localhost:9529/message", sender);
            await client.StartAsync();

            var input = string.Empty;
            while (input != "exit")
            {
                input = Console.ReadLine();
                var message = new Message { Content = input, Receiver = receiver };
                await client.SendAsync(message);
            }

            await client.StopAsync();
            Console.WriteLine("客户端退出, 消息中心连接结束!");
        }
    }
}
